<?php
/**
 * 
 * @author Paolo Bertuzzo
 *
 */
namespace User\Data;

class StateDao extends AbstractDao
{
    
    /**
     * 
     */
    public function get() 
    {
        $query = $this->entityManager->createQuery('select s from User\Entity\State s');
        
        $query->useResultCache(true);
        
        return $query->getResult();
    }
        
    /**
     *
     * @param integer $stateId
     */
    public function getById($stateId)
    {
    	$query = $this->entityManager->createQuery('select s from User\Entity\State s where s.stateId = ?1');
    
    	$query->setParameter(1, $stateId);
    	$query->useResultCache(true);
    
    	$result = $query->getResult();
    
    	return count($result) == 0 ? null : $result[0];
    }
    
}

?>